home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 July / CHIP_CD_2005-07.iso / software / att / attsetup.exe / plugins / shared memory / VC / attsharedmemDlg.cpp < prev    next >
C/C++ Source or Header  |  2005-03-03  |  4KB  |  134 lines

  1. // attsharedmemDlg.cpp : implementation file
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "attsharedmem.h"
  6. #include "attsharedmemDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13. //
  14.  
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CAttsharedmemDlg dialog
  17.  
  18. CAttsharedmemDlg::CAttsharedmemDlg(CWnd* pParent /*=NULL*/)
  19.     : CDialog(CAttsharedmemDlg::IDD, pParent)
  20. {
  21.     //{{AFX_DATA_INIT(CAttsharedmemDlg)
  22.     //}}AFX_DATA_INIT
  23.     // Note that LoadIcon does not require a subsequent DestroyIcon in Win32
  24.     m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  25. }
  26.  
  27. void CAttsharedmemDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29.     CDialog::DoDataExchange(pDX);
  30.     //{{AFX_DATA_MAP(CAttsharedmemDlg)
  31.     DDX_Control(pDX, IDC_ST1, m_Static1);
  32.     //}}AFX_DATA_MAP
  33. }
  34.  
  35. BEGIN_MESSAGE_MAP(CAttsharedmemDlg, CDialog)
  36.     //{{AFX_MSG_MAP(CAttsharedmemDlg)
  37.     ON_WM_PAINT()
  38.     ON_WM_QUERYDRAGICON()
  39.     ON_WM_TIMER()
  40.     //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // CAttsharedmemDlg message handlers
  45.  
  46. BOOL CAttsharedmemDlg::OnInitDialog()
  47. {
  48.     CDialog::OnInitDialog();
  49.  
  50.     // Set the icon for this dialog.  The framework does this automatically
  51.     //  when the application's main window is not a dialog
  52.     SetIcon(m_hIcon, TRUE);            // Set big icon
  53.     SetIcon(m_hIcon, FALSE);        // Set small icon
  54.     
  55.     hMapObject = OpenFileMapping(FILE_MAP_ALL_ACCESS,TRUE,"ATITRAY_SMEM");    
  56.     if (hMapObject!=0) {
  57.         data = (PATTData)MapViewOfFile(hMapObject, FILE_MAP_WRITE, 0, 0, 0);
  58.     } else {
  59.         data = NULL;
  60.         m_Static1.SetWindowText("ATI Tray Tools not found");
  61.     }
  62.     // TODO: Add extra initialization here
  63.     SetTimer(1,1000,0);
  64.     return TRUE;  // return TRUE  unless you set the focus to a control
  65. }
  66.  
  67. // If you add a minimize button to your dialog, you will need the code below
  68. //  to draw the icon.  For MFC applications using the document/view model,
  69. //  this is automatically done for you by the framework.
  70.  
  71. void CAttsharedmemDlg::OnPaint() 
  72. {
  73.     if (IsIconic())
  74.     {
  75.         CPaintDC dc(this); // device context for painting
  76.  
  77.         SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
  78.  
  79.         // Center icon in client rectangle
  80.         int cxIcon = GetSystemMetrics(SM_CXICON);
  81.         int cyIcon = GetSystemMetrics(SM_CYICON);
  82.         CRect rect;
  83.         GetClientRect(&rect);
  84.         int x = (rect.Width() - cxIcon + 1) / 2;
  85.         int y = (rect.Height() - cyIcon + 1) / 2;
  86.  
  87.         // Draw the icon
  88.         dc.DrawIcon(x, y, m_hIcon);
  89.     }
  90.     else
  91.     {
  92.         CDialog::OnPaint();
  93.     }
  94. }
  95.  
  96. // The system calls this to obtain the cursor to display while the user drags
  97. //  the minimized window.
  98. HCURSOR CAttsharedmemDlg::OnQueryDragIcon()
  99. {
  100.     return (HCURSOR) m_hIcon;
  101. }
  102.  
  103.  
  104. void CAttsharedmemDlg::OnTimer(UINT nIDEvent) 
  105. {
  106.     // TODO: Add your message handler code here and/or call default
  107.     CDialog::OnTimer(nIDEvent);
  108.         if (data!=NULL) {
  109.             char s[1000];
  110.             sprintf(s,"GPU Speed - %dMHz\n"\
  111.                 "MEM Speed - %dMHz\n"\
  112.                 "Current Mode - %s\n"\
  113.                 "Temperature Monitor Supported - %s\n"\
  114.                 "GPU Temperature - %d\n"\
  115.                 "ENV Temperature - %d\n",
  116.                 data->CurGPU, data->CurMEM,
  117.                 ((data->is3DActive==1) ? "3D" : "2D"),
  118.                 ((data->isTempMonSupported==1) ? "Yes" : "No"),
  119.                 data->GPUTemp,data->ENVTemp);
  120.             m_Static1.SetWindowText(s);
  121.                 
  122.         } else  m_Static1.SetWindowText("Error getting ATI Tray Shared Memory Information");
  123.  
  124. }
  125.  
  126. BOOL CAttsharedmemDlg::DestroyWindow() 
  127. {
  128.     // TODO: Add your specialized code here and/or call the base class
  129.     KillTimer(1);
  130.     UnmapViewOfFile(data);
  131.     CloseHandle(hMapObject);
  132.     return CDialog::DestroyWindow();
  133. }
  134.